Deep Learning I
4. 多层感知机
WU Xiaokun 吴晓堃
xkun.wu [at] gmail
2021/03/14
线性意味着单调性假设
Frank Rosenblatt 和I型感知机,1960
感知机
生物神经系统
感知机的组织结构
输入:\mathbf{x};参数:\mathbf{w}, b;输出:
o = \sigma \left( \langle \mathbf{w}, \mathbf{x} \rangle + b\right), \sigma(x) = \left\{ \begin{array}{ll} 1 & \text{if}\ x > 0 \\ 0 & \text{otherwise} \\ \end{array}\right.
激活函数\sigma:输出并传递电信号,激活/未激活
输入:\mathbf{x};参数:\mathbf{w}, b;输出:
o = \sigma \left( \langle \mathbf{w}, \mathbf{x} \rangle + b\right), \sigma(x) = \left\{ \begin{array}{ll} 1 & \text{if}\ x > 0 \\ -1 & \text{otherwise} \\ \end{array}\right.
二分类问题,激活函数通常输出:\{-1,1\}
训练过程等价于使用批量大小为1的梯度下降
[Minsky 1969] 感知机不能拟合XOR函数
| x_1 | x_2 | |
|---|---|---|
| x_1 | 1 | 0 |
| x_2 | 0 | 1 |
| \textcolor{green}{\textbf{1}} | \textcolor{red}{\textbf{2}} | \textcolor{green}{\textbf{3}} | \textcolor{red}{\textbf{4}} | |
|---|---|---|---|---|
| \textcolor{orange}{\textbf{Y}} | + | + | - | - |
| \textcolor{blue}{\textbf{B}} | + | - | - | + |
| \textcolor{green}{\textbf{1}} | \textcolor{red}{\textbf{2}} | \textcolor{green}{\textbf{3}} | \textcolor{red}{\textbf{4}} | |
|---|---|---|---|---|
| \textcolor{orange}{\textbf{Y}} | + | + | - | - |
| \textcolor{blue}{\textbf{B}} | + | - | - | + |
| \textcolor{gray}{\textbf{P}} | \textcolor{green}{\textbf{+}} | \textcolor{red}{\textbf{--}} | \textcolor{green}{\textbf{+}} | \textcolor{red}{\textbf{--}} |
隐藏层:将辅助函数推广到多个
首先考虑隐藏层\textbf{h}
\textbf{h} = \sigma(\textbf{W}^h \textbf{x} + \textbf{b}^h)
其次考虑输出层\textbf{o}
\textbf{o} = \textbf{W}^o \textbf{h} + \textbf{b}^o
\begin{aligned} \textbf{h} &= \sigma(\textbf{W}^h \textbf{x} + \textbf{b}^h)\\ \textbf{o} &= \textbf{W}^o \textbf{h} + \textbf{b}^o\\ \end{aligned}
\begin{aligned} \textbf{z} &= \textbf{W}^h \textbf{x}\\ \textbf{h} &= \phi(\textbf{z})\\ \textbf{o} &= \textbf{W}^o \textbf{h}\\ \mathcal{L} &= l(O,y)\\ \end{aligned}
\begin{aligned} \textbf{H} &= \sigma(\textbf{X} \textbf{W}^h + \textbf{b}^h)\\ \textbf{O} &= \textbf{H} \textbf{W}^o + \textbf{b}^o\\ \end{aligned}
假设\sigma是线性函数
\begin{aligned} \textbf{H} &= \sigma(\textbf{X} \textbf{W}^h + \textbf{b}^h)\\ &= \textbf{W}(\textbf{X} \textbf{W}^h + \textbf{b}^h) + \textbf{b}\\ \textbf{O} &= \textbf{H} \textbf{W}^o + \textbf{b}^o\\ \end{aligned}
ReLU, sigmoid, tanh.
问题:0点处的导数怎么办?简单选取一个值
“如果微妙的边界条件很重要,我们很可能是在研究数学而非工程”
输出是实数,但分类任务需要将输出映射到类别标签
\textbf{o} = \textbf{W}^o \textbf{h} + \textbf{b}^o
转换的关键是激活函数
单、二分类
Sigmoid:映射到[0,
1],是/否Tanh:映射到[-1,
1],两极多分类
softmax:映射到对应类别概率值\begin{aligned} \textbf{h}_1 &= \sigma(\textbf{W}_1 \textbf{x} + \textbf{b}_1)\\ \textbf{h}_2 &= \sigma(\textbf{W}_2 \textbf{h}_1 + \textbf{b}_2)\\ \textbf{h}_3 &= \sigma(\textbf{W}_3 \textbf{h}_2 + \textbf{b}_3)\\ \textbf{o} &= \textbf{W}^o \textbf{h}_3 + \textbf{b}^o\\ \end{aligned}
超参数:取决于模型的设计
多层感知机是第一个深度模型
问题:如何确定超参数?
ReLU, sigmoid,
tanhsoftmax处理多分类任务感知机。多层感知机模型。激活函数。多层感知机的实现。误差分类与验证方法。欠拟合与过拟合。减轻过拟合。
重点:多层感知机模型;激活函数;多层感知机的实现;训练误差、验证误差、泛化误差;欠拟合、过拟合;减轻过拟合:模型容量限制,权重衰减(正则化),丢弃法。
难点:XOR问题;模型泛化性;减轻过拟合。
感知机
欠拟合、过拟合
(*) 简述多层感知机解决XOR问题的方法。
简述为什么多层感知机可以逼近非线性函数?
简述三种基本激活函数的特点和用途。
简述训练误差、验证误差、泛化误差的区别。
简述验证集、测试集的区别,并举例说明验证方法。
结合图示简述欠拟合、过拟合的判断方法,以及过拟合的主要原因。
简述减轻过拟合的两个主要思路,及其主要原理。
简述权重正则化、丢弃法的主要方法和原理。